<?php
/*
Template Name: Music Festival Page
*/
?>

<?php get_header(); ?>
<?php global $woo_options; ?>
       
    <div id="content" class="page col-full">
		<div id="main" class="col-left">
		           
		<?php if ( $woo_options[ 'woo_breadcrumbs_show' ] == 'true' ) { ?>
			<?php woo_breadcrumbs(); ?>  
		<?php } ?>  			

        <?php if (have_posts()) : $count = 0; ?>
        <?php while (have_posts()) : the_post(); $count++; ?>
                                                                    
            <div <?php post_class(); ?>>

			    <h1 class="title"><?php the_title(); ?></h1>

                <!--<div class="entry">-->

<?php // Get The Page Variables

        // Get The Page Image Image / Festival Logo
	if (get_field('productFeaturedImage') != '') {
		$festivallogo = get_field('productFeaturedImage');
	} else {
		$festivallogo = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large');
		$festivallogo = $festivallogo[0];
	}

	$festivaldates = get_field('festivaldates');
	$festivallength = get_field('festivallength');
	$festivallocation = get_field('festivallocation');
	$festivalmap = get_field('festivalmap');
	$festivalwebsite = get_field('festivalwebsite');
	$festivalgenres = get_field('festivalgenres');
	$festivallodging = get_field('festivallodging');
	$festivalproducttypes = get_field('festivalproducttypes');
	$festivalproductids = get_field('festivalproductids');
        $festivalproductlist = explode(",",$festivalproductids);

?>

<style>
	.festivalbox h3 { margin-bottom:0px;clear:none;clear:left; }
	ul.festivaldetailslist { list-style:none;padding-left:0px;margin:0px; }
		ul.festivaldetailslist li { list-style-type:none; }
			ul.festivaldetailslist li span { float:right;text-align:right;font-weight:bold; }
	.festivalproduct { width:145px;min-height:300px;padding:5px;float:left;margin:0px;text-align:center; }
		.festivalproduct:hover { background:#f2f2f2; }
		.festivalproduct p.price ins { display:block;clear:both;text-decoration:none;margin-top:10px; }
			.festivalproduct p.price ins span.amount { font-size:20px;font-weight:bold;color:#3a3f55; }
			
</style>

<div class="festivalbox">
<div style="width:278px;padding:10px;border:#cccccc 1px solid;background:#f2f2f2;float:left;margin:0px;margin-bottom:10px;">
	<h3>Festival Details:</h3>
	<ul class="festivaldetailslist">
		<li>Festival:<span><?php the_title(); ?></span></li>
		<li>Dates:<span><?php echo $festivaldates; ?></span></li>
		<li>Location:<span><?php echo $festivallocation; ?></span></li>
		<li>Website:<span><a href="http://<?php echo $festivalwebsite; ?>" target="_blank"><?php echo $festivalwebsite; ?></a></span></li>
	</ul>
</div>

<div style="width:300px;float:right;margin:0px;margin-left:20px;margin-bottom:10px;">
	<img src="<?php echo $festivallogo; ?>" alt="<?php the_title(); ?>" style="width:288px;height:auto;margin:0px;" />
</div>

<h3>Description:</h3>
<?php the_content(); ?>

<div style="width:300px;float:left;margin:0px;margin-right:20px;">
	<h2 class="pagesubsectionheader">Additional Information</h2>
	<p><span style="font-weight:bold;">Location:</span><br/>
	<?php echo $festivallocation; ?></p>
	<p><span style="font-weight:bold;">Length:</span><br/>
	<?php echo $festivallength; ?> days</p>
	<p><span style="font-weight:bold;">Genres:</span><br/>
	<?php echo $festivalgenres; ?></p>
	<p><span style="font-weight:bold;">Lodging Options:</span><br/>
	<?php the_field('festivallodging'); ?></p>
	<p><span style="font-weight:bold;">Recommended Solar Products:</span><br/>
	<?php the_field('festivalproducttypes'); ?></p>
</div>
<div style="width:300px;float:left;margin:0px;">
	<h2 class="pagesubsectionheader">Map &amp; Directions</h2>
	<?php the_field('festivalmap'); ?>
</div>

<h2 class="pagesubsectionheader">Recommended Solar Products For <?php the_title(); ?></h2>

<?php 
	$args = array(
		'post_type' => 'product',
		'post__in' => $festivalproductlist
	);

	$festivalproducts = new wp_query($args);
	while($festivalproducts->have_posts()) : $festivalproducts->the_post();
	
	// Get The Product Featured Image
	if (get_field('productFeaturedImage') != '') {
            $productimage = get_field('productFeaturedImage');
	} else {
            $productimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large');
            $productimage = $productimage[0];
	}
?>

		<div class="festivalproduct">
                    <a href="<?php the_permalink(); ?>">
                        <img src="<?php echo $productimage; ?>" alt="<?php the_title(); ?>" style="width:133px;height:133px;" />
                    </a>
                    <h3><a href="<?php the_permalink(); ?>"><?php the_titlesmall('', '', true, '30'); ?></a></h3>
                    <?php include '/home/silicons/public_html/wp-content/themes/woostore/woocommerce/single-product/price.php'; ?>
                    <p><a href="<?php the_permalink(); ?>" class="button">View Product</a></p>
		</div>
	
	<?php endwhile; ?>
	<?php wp_reset_query(); ?>

<div style="width:100%;height:0px;clear:both;"></div>
</div><!-- .festivalbox -->

               	<!--</div><!-- /.entry -->

				<?php edit_post_link( __( '{ Edit }', 'woothemes' ), '<span class="small">', '</span>' ); ?>
                
            </div><!-- /.post -->
                                                
		<?php endwhile; else: ?>
			<div <?php post_class(); ?>>
            	<p><?php _e( 'Sorry, no posts matched your criteria.', 'woothemes' ) ?></p>
            </div><!-- /.post -->
        <?php endif; ?>  
        
		</div><!-- /#main -->

        <?php get_sidebar(); ?>

    </div><!-- /#content -->
		
<?php get_footer(); ?>